/*
 * Copyright (c) JiaChaoYang 2023-7-27 MongoPlus版权所有
 * 适度编码益脑，沉迷编码伤身，合理安排时间，享受快乐生活。
 * email: j15030047216@163.com
 * phone: 15030047216
 * weChat: JiaChaoYang_
 */

package com.anwen.mongoa.controller;

import cn.hutool.json.JSONUtil;
import com.anwen.mongo.mapper.BaseMapper;
import com.anwen.mongoa.entity.User;
import io.swagger.annotations.Api;
import lombok.extern.log4j.Log4j2;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * @author JiaChaoYang
 * 所有时间：[1855,2517,2509,2498,2508,2511,2516,2509,2512,2520,2502,2526,2499,2515,2514,2515,2515,2521,2494,2523,2523,2496,2727,2302,2507,2527,2497,2544,2483,2514,2511,2511,2522,2504,2513,2524,2734,2315,2475,2512,2515,2517,2507,2514,2513,2514,2516,2504,2513,2516,2722,2303,2505,2521,2508,2520,2516,2503,2519,2511,2507,2516,2525,2499,2514,2513,2516,2538,2507,2489,2510,2516,2541,2485,2508,2505,2523,2508,2513,2512,2531,2516,2486,2515,2523,2506,2727,2295,2516,2552,2473,2509,2514,2511,2505,2524,2507,2510,2515,2514,2509,2521,2510,2507,2517,2509,2517,2507,2723,2305,2510,2509,2511,2526,2502,2516,2511,2509,2507,2516,2517,2517,2515,2501,2520,2513,2512,2516,2715,2302,2510,2514,2521,2508,2525,2527,2486,2516,2510,2509,2513,2510,2525,2509,2575,2449,2515,2529,2499,2504,2514,2520,2504,2510,2516,2512,2505,2549,2481,2511,2512,2515,2524,2636,2585,2310,2511,2505,2513,2516,2507,2723,2308,2512,2511,2510,2540,2531,2465,2510,2514,2534,2495,2503,2520,2522,2500,2510,2517,2514,2509,2517,2513,2509,2513,2505,2733,2328,2481,2556,2478,2509,2507,2511,2511,2515,2518,2514,2538,2485,2504,2519,2510,2542,2486,2514,2518,2523,2502,2516,2512,2511,2722,2330,2484,2545,2484,2519,2501,2515,2509,2520,2509,2722,2312,2500,2516,2510,2520,2716,2303,2512,2515,2508,2514,2516,2651,2383,2517,2495,2514,2533,2488,2517,2509,2523,2504,2521,2506,2531,2499,2511,2506,2515,2513,2509,2534,2510,2607,2404,2552,2477,2506,2514,2522,2500,2520,2504,2507,2615,2417,2512,2511,2509,2533,2504,2509,2514,2523,2505,2506,2515,2513,2511,2509,2511,2514,2514,2509,2525,2502,2515,2510,2513,2517,2507,2518,2506,2517,2515,2509,2517,2505,2513,2512,2518,2512,2512,2513,2511,2515,2507,2515,2543,2485,2515,2507,2510,2728,2517,2302,2508,2507,2517,2511,2510,2514,2513,2512,2511,2512,2514,2519,2508,2522,2501,2515,2725,2301,2518,2506,2514,2525,2501,2509,2517,2717,2316,2508,2517,2514,2504,2514,2516,2516,2503,2514,2514,2510,2515,2511,2725,2301,2510,2519,2513,2715,2517,2313,2499,2516,2516,2563,2458,2513,2513,2506,2527,2509,2509,2530,2699,2301,2510,2547,2695,2298,2519,2514,2508,2513,2513,2514,2506,2514,2521,2505,2521,2517,2503,2509,2517,2517,2541,2479,2720,2305,2514,2514,2515,2504,2511,2512,2525,2504,2515,2506,2511,2520,2519,2511,2507,2522,2503,2512,2536,2534,2682,2300,2666,2359,2520,2504,2517,2516,2718,2299,2523,2514,2499,2515,2517,2513,2511,2508,2512,2512,2517,2547,2483,2508,2518,2510,2510,2514,2517,2514,2518,2500,2726,2318,2503,2514,2717,2303,2509,2728,2304,2720,2306,2506,2523,2502,2520,2507,2512,2508,2515,2511,2513,2512,2514,2525,2509,2522,2494,2512,2539,2497,2510,2515,2517,2506,2516,2520,2500,2521,2508,2516,2507,2517,2518,2509,2517,2501,2526,2501,2513,2511,2542,2484,2719,2300,2519,2505,2519,2511,2543,2486,2538,2479,2523,2506,2522,2501,2515,2507,2520,2514,2721,2307,2503,2519,2520,2513,2500,2517,2508,2520,2512,2507,2514,2519,2509,2506,2517,2510,2509,2521,2504,2512,2723,2310,2517,2507,2518,2508,2512,2520,2504,2518,2513,2520,2514,2721,2330,2485,2510,2518,2513,2518,2506,2509,2517,2510,2513,2509,2525,2499,2581,2453,2618,2447,2475,2516,2512,2718,2335,2514,2480,2516,2718,2331,2488,2510,2517,2514,2514,2512,2510,2520,2719,2330,2483,2517,2512,2507,2517,2510,2514,2509,2523,2510,2518,2510,2507,2516,2516,2509,2514,2722,2311,2506,2519,2506,2515,2507,2524,2505,2525,2515,2503,2514,2544,2585,2416,2513,2511,2515,2512,2508,2516,2515,2515,2518,2509,2717,2305,2516,2504,2513,2510,2555,2472,2515,2511,2508,2518,2520,2527,2497,2513,2510,2526,2519,2514,2516,2505,2520,2654,2370,2732,2290,2507,2519,2718,2334,2482,2517,2508,2514,2519,2515,2541,2481,2520,2513,2506,2513,2514,2516,2513,2509,2522,2506,2514,2516,2501,2520,2515,2517,2514,2724,2301,2723,2305,2510,2522,2514,2506,2514,2523,2522,2498,2533,2497,2509,2513,2517,2509,2509,2515,2517,2720,2301,2517,2507,2516,2724,2295,2530,2517,2502,2525,2504,2725,2304,2510,2512,2520,2513,2509,2510,2614,2412,2522,2503,2519,2514,2714,2304,2530,2502,2511,2520,2513,2513,2517,2503,2511,2514,2544,2482,2530,2504,2516,2520,2503,2515,2518,2512,2515,2509,2546,2492,2505,2515,2719,2304,2515,2526,2503,2513,2515,2506,2510,2526,2512,2547,2478,2511,2528,2497,2513,2515,2512,2520,2510,2597,2435,2510,2521,2506,2509,2517,2506,2525,2518,2506,2514,2519,2532,2515,2508,2524,2508,2525,2511,2501,2513,2546,2479,2516,2513,2518,2513,2521,2513,2519,2510,2512,2509,2513,2536,2481,2729,2301,2728,2299,2514,2517,2515,2519,2516,2502,2544,2482,2526,2508,2515,2512,2519,2536,2490,2537,2489,2515,2516,2541,2742,2246,2737,2293,2547,2484,2517,2515,2508,2509,2519,2522,2504,2514,2509,2508,2523,2508,2514,2510,2725,2300,2722,2302,2521,2513,2518,2729,2312,2529,2515,2524,2516,2513,2508,2722,2302,2511,2521,2508,2518,2515,2515,2515,2518,2541,2488,2505,2510,2511,2526,2503,2512,2518,2521,2505,2516,2531,2532,2488,2499,2517,2518,2504,2514,2519,2516,2500,2519,2515,2525,2502,2519,2524,2524,2497,2524,2503,2523,2508,2511,2509,2518,2518,2505,2511,2528,2504,2520,2508,2512,2542,2512,2495,2507,2509,2513,2521,2509,2522,2509,2553,2483,2500,2523,2507,2510,2514,2523,2516,2506,2510,2743,2305,2718,2301,2531,2499,2517,2519,2516,2508,2511,2513,2556,2469,2728,2297,2520,2515,2526,2495]
 * 平均值：2512.328671328671    2480.3636363636365
 * 所有时间：[1945,2498,2512,2523,2503,2534,2500,2516,2502,2520,2508,2515,2512,2520,2519,2522,2510,2526,2513,2523,2507,2533,2494,2530,2507,2524,2497,2518,2507,2528,2537,2693,2302,2517,2510,2515,2505,2522,2518,2517,2735,2292,2520,2541,2490,2510,2515,2513,2507,2546,2498,2514,2509,2512,2508,2526,2514,2506,2519,2506,2516,2520,2509,2530,2515,2727,2297,2542,2510,2493,2516,2511,2546,2484,2507,2526,2514,2714,2312,2505,2533,2512,2510,2518,2506,2520,2730,2303,2520,2510,2526,2509,2513,2535,2500,2500,2528,2502,2512,2524,2500,2532,2516,2504,2518,2504,2510,2529,2509,2508,2526,2520,2525,2517,2507,2512,2524,2503,2514,2538,2490,2514,2548,2483,2517,2513,2517,2511,2520,2536,2491,2514,2510,2522,2495,2525,2534,2502,2517,2517,2506,2518,2526,2515,2496,2523,2517,2506,2515,2515,2511,2515,2511,2524,2510,2527,2497,2520,2517,2526,2500,2523,2520,2505,2521,2509,2520,2511,2513,2519,2500,2526,2511,2540,2483,2517,2516,2504,2520,2519,2501,2514,2527,2509,2506,2517,2517,2510,2510,2517,2513,2510,2510,2518,2525,2514,2506,2507,2529,2513,2504,2504,2518,2524,2506,2520,2510,2549,2485,2500,2522,2509,2518,2524,2497,2559,2468,2511,2521,2506,2518,2513,2511,2512,2529,2497,2535,2708,2311,2521,2496,2519,2508,2518,2511,2525,2518,2510,2515,2499,2727,2332,2497,2522,2505,2520,2519,2494,2515,2727,2307,2714,2310,2509,2517,2547,2477,2516,2509,2515,2511,2540,2482,2517,2516,2720,2306,2513,2515,2513,2523,2505,2509,2518,2553,2683,2310,2508,2514,2686,2341,2551,2484,2513,2507,2512,2515,2508,2516,2513,2517,2545,2470,2514,2524,2510,2724,2300,2504,2516,2511,2520,2511,2510,2521,2508,2518,2507,2515,2514,2521,2509,2727,2314,2499,2517,2514,2513,2516,2504,2517,2503,2521,2519,2508,2514,2506,2729,2301,2509,2515,2507,2523,2509,2516,2607,2425,2563,2457,2520,2508,2508,2551,2477,2517,2504,2527,2680,2329,2523,2510,2512,2519,2513,2500,2517,2516,2512,2519,2499,2519,2516,2521,2504,2519,2516,2503,2509,2517,2518,2513,2517,2504,2524,2505,2514,2507,2519,2545,2480,2732,2298,2506,2548,2479,2512,2518,2512,2514,2516,2502,2527,2502,2515,2523,2714,2525,2325,2479,2528,2503,2516,2509,2516,2507,2521,2507,2518,2504,2509,2520,2511,2527,2503,2513,2509,2513,2518,2508,2724,2310,2507,2508,2728,2298,2515,2522,2507,2538,2481,2516,2509,2519,2513,2521,2504,2515,2525,2500,2548,2486,2503,2516,2726,2296,2515,2516,2508,2510,2514,2516,2502,2522,2514,2509,2509,2512,2511,2525,2510,2518,2539,2490,2508,2518,2514,2511,2507,2542,2490,2509,2508,2524,2505,2544,2474,2520,2512,2512,2520,2540,2482,2524,2509,2500,2730,2305,2503,2730,2309,2499,2509,2518,2516,2506,2514,2513,2512,2509,2516,2529,2505,2519,2507,2521,2511,2502,2516,2515,2522,2758,2265,2511,2512,2521,2510,2549,2683,2308,2514,2508,2515,2719,2306,2516,2517,2501,2518,2505,2518,2512,2557,2470,2518,2504,2518,2515,2511,2506,2519,2519,2510,2516,2508,2520,2512,2508,2507,2514,2524,2508,2500,2524,2514,2508,2524,2511,2503,2519,2509,2517,2513,2534,2486,2513,2512,2524,2508,2513,2520,2507,2509,2504,2519,2518,2503,2518,2509,2526,2499,2712,2320,2512,2512,2516,2510,2526,2536,2484,2509,2503,2517,2510,2511,2519,2717,2348,2471,2552,2473,2511,2729,2306,2519,2510,2516,2499,2521,2519,2509,2515,2717,2304,2518,2510,2517,2515,2513,2505,2549,2513,2480,2508,2515,2507,2521,2516,2515,2505,2513,2723,2305,2516,2524,2613,2404,2513,2508,2522,2508,2520,2503,2723,2307,2512,2514,2510,2509,2551,2747,2919,2884,2759,2512,2506,2824,2526,2529,2502,2526,2510,2517,2515,2512,2509,2511,2509,2523,2505,2513,2511,2513,2514,2516,2560,2501,2525,2505,2511,2529,2504,2506,2511,2527,2514,2516,2535,2509,2482,2514,2519,2506,2722,2511,2304,2524,2506,2511,2516,2518,2514,2506,2521,2507,2514,2721,2304,2538,2478,2516,2519,2507,2505,2523,2501,2513,2523,2512,2528,2501,2535,2487,2514,2513,2512,2526,2514,2521,2507,2504,2526,2507,2505,2519,2503,2524,2512,2511,2516,2506,2514,2517,2521,2505,2511,2509,2521,2506,2512,2719,2307,2512,2526,2496,2519,2513,2515,2514,2506,2524,2512,2498,2518,2517,2513,2512,2718,2304,2513,2523,2510,2514,2502,2523,2513,2512,2507,2510,2518,2512,2719,2298,2515,2519,2506,2518,2512,2509,2519,2509,2515,2508,2512,2510,2512,2515,2523,2512,2510,2507,2518,2516,2502,2519,2517,2519,2502,2511,2518,2528,2507,2514,2501,2514,2508,2525,2511,2512,2520,2501,2514,2515,2511,2513,2510,2508,2515,2521,2515,2505,2517,2514,2506,2517,2516,2511,2509,2508,2516,2513,2512,2518,2515,2509,2514,2513,2521,2500,2510,2725,2297,2730,2332,2640,2359,2505,2514,2519,2511,2506,2521,2517,2508,2539,2482,2514,2517,2522,2503,2522,2503,2720,2307,2510,2528,2508,2504,2519,2496,2524,2516,2504,2516,2530,2505,2505,2518,2645,2407,2488,2509,2517,2534,2484,2513,2516,2507,2723,2307,2515,2512,2519,2521,2502,2505,2517,2511,2507,2517,2507,2517,2515,2540,2484,2518,2513,2507,2510,2507,2514,2516,2516,2528,2490,2517,2517,2515,2509,2513,2515,2505,2511,2519,2508,2725,2302,2516,2515,2518,2504,2514,2518,2508,2510,2527,2513,2509,2510,2514,2511,2511,2521,2515,2496,2516,2516,2501,2531,2531,2485,2518,2517,2500,2514,2517,2516,2505,2567,2455,2512,2534,2505,2499,2524,2507,2510,2513,2514,2515,2515,2517,2509,2511,2519,2510,2514,2519,2507,2519,2519,2515,2508,2517,2510,2513,2508,2527,2509,2510,2506,2519]
 * 平均值：2514.3836163836163
 * @project mongo-plus-demo
 * @description
 * @date 2023-07-18 21:38
 **/
@Api(tags = "测试")
@RestController
@Log4j2
public class TestController extends BaseMapper<User> {

    @Resource
    private MongoTemplate mongoTemplate;

/*    @GetMapping("/findAll")
    public Object findAll(){
        long count = mongoOperate.lambdaQuery().count("user");
        long action = System.currentTimeMillis();
        log.info("mongoPlus开始时间：{}",action);
        List<Map<String, Object>> mapList = mongoOperate.list("user");
        long end = System.currentTimeMillis();
        log.info("mongoPlus结束时间：{}",end);
        log.error("耗时：{}",end-action);
        long a = System.currentTimeMillis();
        log.info("开始时间：{}",a);
        List<Map<String,Object>> map = new ArrayList<>();
        Iterator<Map<String, Object>> mapIterator = mapList.iterator();
        while (mapIterator.hasNext()){
            map.add(mapIterator.next());
        }
        long b = System.currentTimeMillis();
        log.info("结束时间：{}",b);
        log.error("耗时：{}",b-a);
        return map;
    }*/

    @GetMapping("/findMongoAll")
    public Object findMongoAll(){
        return lambdaQuery().eq(User::getUserAge,18).list();
    }

}
